home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
windows
/
pmcstex.zip
/
PM4EPM.E
< prev
next >
Wrap
Text File
|
1996-05-17
|
17KB
|
484 lines
/*
pm4epm.e
PM for EPM. pm_command family: command with expansion dependend
on the currently edited file
c Petr Mikulík - Brno - Czech Republic - 20.2.1996
mikulik@physics.muni.cz, http://www.sci.muni.cz/~mikulik/
Update for emtex options: 17.5.1996
Update for dvips options: 15.5.1996
*/
/*
USAGE: I use this macro file for actions on the EPM toolbar, and in the package
CSTeX that implements menu for many (La)TeX related commands.
INSTALLATION:
1. cite this file (pm4epm) in the actions.lst file
2. write include pm4epm into your Profile.erx
3. You should have already installed EPMTeX and WETEX by Wagner
COMMANDS DEFINED HERE:
pm_expand - expands the string and then executes it
pm_command_os2 - expands the string and runs it as os2 program
pm_command_os2fs - expands the string and runs full-screen os2 program
pm_command_cmd - expands the string and runs it through cmd
pm_command_pm - expands the string and runs it (only START)
pm_command_dos - expands the string and runs it as dos program
pm_command_dosfs - expands the string and runs full-screen dos program
etc.
The expansion depends on the edited file (currently active file in the editor).
SYNTAX of pm_expand WITH EXAMPLE: work file is e:\tmp\a.tex =>
Syntax Internal Variable Explanation Example
%w EFname work file name a
%.w EFext work file extension tex
%W EFwholename full name without extension e:\tmp\a
%.W EF full name e:\tmp\a.tex
The same holds for the Master file specified by the MASTER: key (see below):
%m %.m %M %.M
Both types written in the Unix format (i.e. backslahes replaced by slashes):
%x %.x %X %.X for the work file e.g. %.X = e:/tmp/a.tex
%n %.n %N %.N for the master file
%h MFdrive drive of the master file (e:)
%d MainDirectory directory of the master file (\tmp)
%D XMainDirectory directory in the Unix format (/home/petr/tex)
Key specifications:
The work file can have some of the following keyword written on its first line.
They are expanded as well according to this rules:
Syntax Internal Variable Introducing key word If key not specified
%master MF Master: MF := EF
%format TheFormat Format: envir. var. TEXFORMATDEFAULT
of "latex"
%etc TheEtc Etc: empty string
%orient TheOrient Orientation: empty string
%choice TheChoice Choice: empty string
The following are expanded as verbatims, e.i. from the first char occuring after
the key to the next same char:
%opts Opts: empty string
%viewopts ViewOpts: empty string
%optsdvips dvips: empty string
%optsemtex EmtexOpt: empty string
The syntax $(Name) expands environmental variable Name
*** Example 1 ***
We edit file E:\TEXT\FERDA.TEX having the first line
% Master: SEKORA.TEX Format: latex209 Choice: none
Then commands are expanded:
"copy %.W %W.old" => "copy E:\TEXT\FERDA.TEX E:\TEXT\FERDA.old"
"type %w%.w" => "type FERDA.TEX"
"%format.cmd %.N" => "latex209.cmd E:/TEXT/SEKORA.TEX"
"echo %choice *%etc*" => "echo none **"
*** Example 2 ***
We edit file E:\TEXT\BROUK.TEX having the first line
% ViewOpts: +/tr1 /m1440+ Etc: does not exist Opts: =any other=
"start cmd /c cykl %.W %format.cmd %N" =>
"start cmd /c cykl E:\TEXT\BROUK.TEX latex.cmd E:/TEXT/BROUK"
"start /fs dviscr %viewopts %M.dvi" =>
"start /fs dviscr /tr1 /m1440 e:\text\brouk.dvi"
*/
include 'stdconst.e'
/************************ CONSTANTS *********************************/
const
PM_STARTos2 = 'start /C /WIN '
PM_STARTos2fs = 'start /C /FS '
PM_STARTcmd = 'start /C /WIN cmd /c '
PM_STARTpm = 'start '
PM_STARTdos = 'start /C /WIN /DOS command.com /c '
PM_STARTdosfs = 'start /C /FS /DOS command.com /c '
/* Message strings */
pm_expand_inf = "Expand command with: Work file: %w (name) %.w (ext) %W (path\name) %.W (full name); Main drive:\dir %d; 'MASTER:' file: %m %.m %M %.M; 'FORMAT:' %format 'ORIENTATION:' %orient; 'ETC:' %etc; 'CHOICE:' %choice; Verbatims: 'EMTEXOPT:' %optsemtex; 'DVIPS:' %optsdvips; 'VIEWOPTS:' %viewopts; 'OPTS:' %opts"
pm_command_os2_inf = "Expand command line (as pm_expand) and execute OS/2 exe program"
pm_command_os2fs_inf = "Expand command line (as pm_expand) and execute full-screen OS/2 exe program"
pm_command_cmd_inf = "Expand command line (as pm_expand) and execute .cmd file"
pm_command_pm_inf = "Expand command line (as pm_expand) and execute Prezentation Manager program"
pm_command_dos_inf = "Expand command line (as pm_expand) and execute dos exe program"
pm_command_dosfs_inf = "Expand command line (as pm_expand) and execute dos exe program (full screen)"
/* The following command adds the action commands to the list */
DEFINIT
universal pm4epm_MasterNotFound
DEFC pm4epm_actionlist
universal ActionsList_FileID
insertline 'pm_expand'pm_expand_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
insertline 'pm_command_cmd'pm_command_cmd_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
insertline 'pm_command_os2'pm_command_os2_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
insertline 'pm_command_os2fs'pm_command_os2fs_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
insertline 'pm_command_pm'pm_command_pm_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
insertline 'pm_command_dos'pm_command_dos_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
insertline 'pm_command_dosfs'pm_command_dosfs_inf'pm4epm',ActionsList_FileID.last+1,ActionsList_FileID
/*************************** ROUTINES ******************************/
DEFPROC PM_GetNextWord ( WhichWord, line, uline )
-- routine returns the next word after the keyword WhichWord or WhichWord:
i = wordpos(WhichWord,uline)
if i=0 then i = wordpos(WhichWord':',uline) endif
if i=words(uline) then i=0; TheWord='' endif
if i<>0 then TheWord=word(line,i+1)
else TheWord=''
endif
return TheWord
DEFPROC PM_GetNextWordOptions ( WhichWord, line, uline )
-- routine scans for WhichWord. The first char of the next word as taken as the
-- key char. Then line is copied to TheOpts until the next key char appears.
-- This is similar to \verb*TheOpts...* in LaTeX
i = wordpos(WhichWord,uline)
if i=0 then i = wordpos(WhichWord':',uline) endif
if i=words(uline) then i=0; TheOpts='' endif
if i<>0
then TheOpts=subword(line,i+1,words(line)-i)
KeyChar=substr(TheOpts,1,1); TheOpts=delstr(TheOpts,1,1)
i=pos(KeyChar,TheOpts)
if (i<>0) then TheOpts=substr(TheOpts,1,i-1) endif
else TheOpts=''
endif
return TheOpts
DEFPROC PM_SubstKeys ( TheCommand, TheKey, ByWhat )
-- routine substitutes TheKey strings by ByWhat strings in TheCommand
i = pos(TheKey,TheCommand)
do while (i<>0)
l = length(TheKey)
TheCommand = substr(TheCommand,1,i-1)ByWhat''substr(TheCommand,i+l,length(TheCommand)-i-l+1)
i = pos(TheKey,TheCommand)
end
return TheCommand
DEFPROC PM_SubstEnvironment ( TheCommand )
-- routine substitutes the environmental variables (like $(PATH)) within TheCommand
i = pos('$(',TheCommand)
do while (i<>0)
e = substr(TheCommand,i+2,length(TheCommand)-i-2)
TheCommand = substr(TheCommand,1,i-1)
i = pos(')',e)
if i>0
then TheCommand=TheCommand''get_env(substr(e,1,i-1))''substr(e,i+1,length(e)-i-1)
else TheCommand=TheCommand''get_env(substr(e,1,length(e)))
endif
i = pos('$(',TheCommand)
end
return TheCommand
DEFPROC save_the_ring() =
n = filesinring()
for i = 1 to n
if .modif